package com.example;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Gallery;
import android.widget.ImageView;

/**
 * Custom view for this app. Sets up a proper layout and all listeners.
 */
public class TouchableView2 extends View {

    public Drawable shapeDrawable;
    int alpha = 255;

    public TouchableView(final Context context, final AttributeSet attrs) {
        super(context, attrs);

        final int x = 10;
        final int y = 10;
        final int width = 150;
        final int height = 150;

        final ImageView imageView = new ImageView(context);
        imageView.setImageResource(R.drawable.jpoint);
        imageView.setLayoutParams(new Gallery.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        shapeDrawable = imageView.getDrawable();
        shapeDrawable.setBounds(x, y, x + width, y + height);
        final OnTouchListener myOnTouchListener = new CustomViewOnTouchListener(width, height);
        setOnTouchListener(myOnTouchListener);
    }

    protected void onDraw(Canvas canvas) {
        shapeDrawable.draw(canvas);
    }

}
